# python迭代dict 默认时迭代key
d = {'a': 1, 'b': 2, 'c': 3}
for n in d:
    print(n)


for n in d.values(): # 迭代dict 的value
    print(n)

for k,v in d.items(): # 迭代dict的 kv
    print(k, v)

# 使用collection。abc模块的iterable来判断
from collections.abc import Iterable
print(isinstance('abc',Iterable))
# 习题 使用迭代查找一个list中最小值和最大值，并返回一个tuple


def findMinAndMax(L):
    max = min = None
    if len(L)!=0:
        max=min=L[0]
        for n in L:
            if max <n:
                max=n
            if min>n:
                min=n
        return (min, max)


print(findMinAndMax([1,4,77,8989,44,23,0,6555,33]))
